package com.link.base.base.user.authority;

import com.link.base.base.user.model.User;
import com.link.core.util.PasswordUtil;
import org.springframework.stereotype.Component;

import javax.naming.directory.DirContext;

/**
 * @author unknown
 * @date unknown
 * @comments 用户密码处理
 */
@SuppressWarnings("deprecation")
@Component
public class UserPasswordEncoder {

    /**@Resource
    private LdapShaPasswordEncoder passwordEncoder;*/

    public String encodePassword(String rawPass, Object salt) {
        return null;
    }

    public boolean webserviceValid(String encPass, String rawPass, Long corpId, String userName) {
        User user = new User();
        user.setCorpid(corpId);
        user.setUsername(userName);
        return isPasswordValid(encPass, rawPass, user);
    }

    @SuppressWarnings("unchecked")
    public boolean isPasswordValid(String encPass, String rawPass, Object salt) {

        return PasswordUtil.isEquals(rawPass, encPass);

    }

    /**
     * 根据LDAP用户名密码验证
     *
     * @param userDn
     * @param credentials
     * @return
     */
    public boolean ldapAuthenticate(String userDn, String credentials) {
        DirContext ctx = null;
        return true;

    }


}
